home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Secrets 4 / Hacker's Secrets 4.iso / faq / odd3229.txt < prev    next >
Text File  |  1997-01-06  |  20KB  |  385 lines

  1. Subject: Cryptography FAQ (08/10: Technical Miscellany)
  2. Supersedes: <cryptography-faq/part08_848729385@rtfm.mit.edu>
  3. Date: 14 Dec 1996 06:51:22 GMT
  4. References: <cryptography-faq/part01_850546235@rtfm.mit.edu>
  5. X-Last-Updated: 1994/07/05
  6.  
  7.  
  8. This is the eighth of ten parts of the sci.crypt FAQ. The parts are
  9. mostly independent, but you should read the first part before the rest.
  10. We don't have the time to send out missing parts by mail, so don't ask.
  11. Notes such as ``[KAH67]'' refer to the reference list in the last part.
  12.  
  13. The sections of this FAQ are available via anonymous FTP to rtfm.mit.edu 
  14. as /pub/usenet/news.answers/cryptography-faq/part[xx]. The Cryptography 
  15. FAQ is posted to the newsgroups sci.crypt, talk.politics.crypto, 
  16. sci.answers, and news.answers every 21 days.
  17.  
  18.  
  19.  
  20. Contents
  21.  
  22. 8.1. How do I recover from lost passwords in WordPerfect?
  23. 8.2. How do I break a Vigenere (repeated-key) cipher?
  24. 8.3. How do I send encrypted mail under UNIX? [PGP, RIPEM, PEM, ...]
  25. 8.4. Is the UNIX crypt command secure?
  26. 8.5. How do I use compression with encryption?
  27. 8.6. Is there an unbreakable cipher?
  28. 8.7. What does ``random'' mean in cryptography?
  29. 8.8. What is the unicity point (a.k.a. unicity distance)?
  30. 8.9. What is key management and why is it important?
  31. 8.10. Can I use pseudo-random or chaotic numbers as a key stream?
  32. 8.11. What is the correct frequency list for English letters?
  33. 8.12. What is the Enigma?
  34. 8.13. How do I shuffle cards?
  35. 8.14. Can I foil S/W pirates by encrypting my CD-ROM?
  36. 8.15. Can you do automatic cryptanalysis of simple ciphers?
  37. 8.16. What is the coding system used by VCR+?
  38.  
  39.  
  40. 8.1. How do I recover from lost passwords in WordPerfect?
  41.  
  42.   WordPerfect encryption has been shown to be very easy to break.
  43.   The method uses XOR with two repeating key streams: a typed password
  44.   and a byte-wide counter initialized to 1+<the password length>. Full
  45.   descriptions are given in Bennett [BEN87] and Bergen and Caelli
  46.   [BER91].
  47.  
  48.   Chris Galas writes: ``Someone awhile back was looking for a way to
  49.   decrypt WordPerfect document files and I think I have a solution. 
  50.   There is a software company named: Accessdata (87 East 600 South,
  51.   Orem, UT 84058), 1-800-658-5199 that has a software package that will
  52.   decrypt any WordPerfect, Lotus 1-2-3, Quatro-Pro, MS Excel and Paradox
  53.   files. The cost of the package is $185. Steep prices, but if you
  54.   think your pw key is less than 10 characters, (or 10 char) give them a
  55.   call and ask for the free demo disk. The demo disk will decrypt files
  56.   that have a 10 char or less pw key.'' Bruce Schneier says the phone
  57.   number for AccessData is 801-224-6970.
  58.  
  59. 8.2. How do I break a Vigenere (repeated-key) cipher?
  60.  
  61.   A repeated-key cipher, where the ciphertext is something like the
  62.   plaintext xor KEYKEYKEYKEY (and so on), is called a Vigenere cipher.
  63.   If the key is not too long and the plaintext is in English, do the
  64.   following: 
  65.  
  66.   1. Discover the length of the key by counting coincidences.
  67.   (See Gaines [GAI44], Sinkov [SIN66].) Trying each displacement of
  68.   the ciphertext against itself, count those bytes which are equal. 
  69.   If the two ciphertext portions have used the same key, something
  70.   over 6% of the bytes will be equal. If they have used different
  71.   keys, then less than 0.4% will be equal (assuming random 8-bit bytes
  72.   of key covering normal ASCII text). The smallest displacement which
  73.   indicates an equal key is the length of the repeated key.
  74.  
  75.   2. Shift the text by that length and XOR it with itself. This
  76.   removes the key and leaves you with text XORed with itself. Since
  77.   English has about 1 bit of real information per byte, 2 streams of
  78.   text XORed together has 2 bits of info per 8-bit byte, providing
  79.   plenty of redundancy for choosing a unique decryption. (And in fact
  80.   one stream of text XORed with itself has just 1 bit per byte.)
  81.  
  82.   If the key is short, it might be even easier to treat this as a
  83.   standard polyalphabetic substitution. All the old cryptanalysis
  84.   texts show how to break those. It's possible with those methods, in
  85.   the hands of an expert, if there's only ten times as much text as key.
  86.   See, for example, Gaines [GAI44], Sinkov [SIN66].
  87.  
  88. 8.3. How do I send encrypted mail under UNIX? [PGP, RIPEM, PEM, ...]
  89.  
  90.   Here's one popular method, using the des command:
  91.  
  92.     cat file | compress | des private_key | uuencode | mail
  93.  
  94.   Meanwhile, there is a de jure Internet standard in the works called
  95.   PEM (Privacy Enhanced Mail). It is described in RFCs 1421 through
  96.   1424. To join the PEM mailing list, contact pem-dev-request@tis.com.
  97.   There is a beta version of PEM being tested at the time of this
  98.   writing.
  99.  
  100.   There are also two programs available in the public domain for encrypting
  101.   mail: PGP and RIPEM. Both are available by FTP. Each has its own
  102.   newsgroup: alt.security.pgp and alt.security.ripem. Each has its own FAQ
  103.   as well.
  104.  
  105.   PGP is most commonly used outside the USA since it uses the RSA algorithm
  106.   without a license and RSA's patent is valid only (or at least primarily)
  107.   in the USA.
  108.  
  109.   RIPEM is most commonly used inside the USA since it uses the RSAREF which
  110.   is freely available within the USA but not available for shipment outside
  111.   the USA.
  112.  
  113.   Since both programs use a secret key algorithm for encrypting the body of
  114.   the message (PGP used IDEA; RIPEM uses DES) and RSA for encrypting the
  115.   message key, they should be able to interoperate freely. Although there
  116.   have been repeated calls for each to understand the other's formats and
  117.   algorithm choices, no interoperation is available at this time (as far as
  118.   we know).
  119.  
  120. 8.4. Is the UNIX crypt command secure?
  121.  
  122.   No. See [REE84]. There is a program available called cbw (crypt
  123.   breaker's workbench) which can be used to do ciphertext-only attacks
  124.   on files encrypted with crypt. One source for CBW is [FTPCB].
  125.  
  126. 8.5. How do I use compression with encryption?
  127.  
  128.   A number of people have proposed doing perfect compression followed by
  129.   some simple encryption method (e.g., XOR with a repeated key).  This
  130.   would work, if you could do perfect compression.  Unfortunately, you can
  131.   only compress perfectly if you know the exact distribution of possible
  132.   inputs, and that is almost certainly not possible.
  133.  
  134.   Compression aids encryption by reducing the redundancy of the plaintext.
  135.   This increases the amount of ciphertext you can send encrypted under a
  136.   given number of key bits.  (See "unicity distance")
  137.  
  138.   Nearly all practical compression schemes, unless they have been designed
  139.   with cryptography in mind, produce output that actually starts off with
  140.   high redundancy. For example, the output of UNIX compress begins with a
  141.   well-known three-byte ``magic number''.  This produces a field of "known
  142.   plaintext" which can be used for some forms of cryptanalytic attack.
  143.   Compression is generally of value, however, because it removes other
  144.   known plaintext in the middle of the file being encrypted.  In general,
  145.   the lower the redundancy of the plaintext being fed an encryption
  146.   algorithm, the more difficult the cryptanalysis of that algorithm.
  147.  
  148.   In addition, compression shortens the input file, shortening the output
  149.   file and reducing the amount of CPU required to do the encryption
  150.   algorithm, so even if there were no enhancement of security, compression
  151.   before encryption would be worthwhile.
  152.  
  153.   Compression after encryption is silly.  If an encryption algorithm is
  154.   good, it will produce output which is statistically indistinguishable
  155.   from random numbers and no compression algorithm will successfully
  156.   compress random numbers.  On the other hand, if a compression algorithm
  157.   succeeds in finding a pattern to compress out of an encryption's output,
  158.   then a flaw in that algorithm has been found.
  159.  
  160. 8.6. Is there an unbreakable cipher?
  161.  
  162.   Yes. The one-time pad is unbreakable; see part 4. Unfortunately the
  163.   one-time pad requires secure distribution of as much key material as
  164.   plaintext.
  165.  
  166.   Of course, a cryptosystem need not be utterly unbreakable to be
  167.   useful. Rather, it needs to be strong enough to resist attacks by
  168.   likely enemies for whatever length of time the data it protects is
  169.   expected to remain valid.
  170.  
  171. 8.7. What does ``random'' mean in cryptography?
  172.  
  173.   Cryptographic applications demand much more out of a pseudorandom
  174.   number generator than most applications. For a source of bits to be
  175.   cryptographically random, it must be computationally impossible to
  176.   predict what the Nth random bit will be given complete knowledge of
  177.   the algorithm or hardware generating the stream and the sequence of
  178.   0th through N-1st bits, for all N up to the lifetime of the source.
  179.  
  180.   A software generator (also known as pseudo-random) has the function
  181.   of expanding a truly random seed to a longer string of apparently
  182.   random bits. This seed must be large enough not to be guessed by
  183.   the opponent. Ideally, it should also be truly random (perhaps
  184.   generated by a hardware random number source).
  185.  
  186.   Those who have Sparcstation 1 workstations could, for example,
  187.   generate random numbers using the audio input device as a source of
  188.   entropy, by not connecting anything to it. For example,
  189.  
  190.         cat /dev/audio | compress - >foo
  191.  
  192.   gives a file of high entropy (not random but with much randomness in
  193.   it). One can then encrypt that file using part of itself as a key,
  194.   for example, to convert that seed entropy into a pseudo-random
  195.   string.
  196.  
  197.   When looking for hardware devices to provide this entropy, it is
  198.   important really to measure the entropy rather than just assume that
  199.   because it looks complicated to a human, it must be "random". For
  200.   example, disk operation completion times sound like they might be
  201.   unpredictable (to many people) but a spinning disk is much like a
  202.   clock and its output completion times are relatively low in entropy.
  203.  
  204. 8.8. What is the unicity point (a.k.a. unicity distance)?
  205.  
  206.   See [SHA49]. The unicity distance is an approximation to that amount
  207.   of ciphertext such that the sum of the real information (entropy) in
  208.   the corresponding source text and encryption key equals the number
  209.   of ciphertext bits used. Ciphertexts significantly longer than this
  210.   can be shown probably to have a unique decipherment. This is used to
  211.   back up a claim of the validity of a ciphertext-only cryptanalysis. 
  212.   Ciphertexts significantly shorter than this are likely to have
  213.   multiple, equally valid decryptions and therefore to gain security
  214.   from the opponent's difficulty choosing the correct one.
  215.  
  216.   Unicity distance, like all statistical or information-theoretic
  217.   measures, does not make deterministic predictions but rather gives
  218.   probabilistic results: namely, the minimum amount of ciphertext
  219.   for which it is likely that there is only a single intelligible
  220.   plaintext corresponding to the ciphertext, when all possible keys
  221.   are tried for the decryption. Working cryptologists don't normally
  222.   deal with unicity distance as such. Instead they directly determine
  223.   the likelihood of events of interest.
  224.  
  225.   Let the unicity distance of a cipher be D characters. If fewer than
  226.   D ciphertext characters have been intercepted, then there is not
  227.   enough information to distinguish the real key from a set of
  228.   possible keys. DES has a unicity distance of 17.5 characters,
  229.   which is less than 3 ciphertext blocks (each block corresponds to
  230.   8 ASCII characters). This may seem alarmingly low at first, but
  231.   the unicity distance gives no indication of the computational work
  232.   required to find the key after approximately D characters have been
  233.   intercepted.
  234.  
  235.   In fact, actual cryptanalysis seldom proceeds along the lines used
  236.   in discussing unicity distance. (Like other measures such as key
  237.   size, unicity distance is something that guarantees insecurity if
  238.   it's too small, but doesn't guarantee security if it's high.) Few
  239.   practical cryptosystems are absolutely impervious to analysis; all
  240.   manner of characteristics might serve as entering ``wedges'' to crack
  241.   some cipher messages. However, similar information-theoretic
  242.   considerations are occasionally useful, for example, to determine a
  243.   recommended key change interval for a particular cryptosystem.
  244.   Cryptanalysts also employ a variety of statistical and
  245.   information-theoretic tests to help guide the analysis in the most
  246.   promising directions.
  247.  
  248.   Unfortunately, most literature on the application of information
  249.   statistics to cryptanalysis remains classified, even the seminal
  250.   1940 work of Alan Turing (see [KOZ84]). For some insight into the
  251.   possibilities, see [KUL68] and [GOO83].
  252.  
  253. 8.9. What is key management and why is it important?
  254.  
  255.   One of the fundamental axioms of cryptography is that the enemy is in
  256.   full possession of the details of the general cryptographic system,
  257.   and lacks only the specific key data employed in the encryption. (Of
  258.   course, one would assume that the CIA does not make a habit of telling
  259.   Mossad about its cryptosystems, but Mossad probably finds out anyway.)
  260.   Repeated use of a finite amount of key provides redundancy that can
  261.   eventually facilitate cryptanalytic progress. Thus, especially in
  262.   modern communication systems where vast amounts of information are
  263.   transferred, both parties must have not only a sound cryptosystem but
  264.   also enough key material to cover the traffic.
  265.  
  266.   Key management refers to the distribution, authentication, and
  267.   handling of keys.
  268.  
  269.   A publicly accessible example of modern key management technology
  270.   is the STU III secure telephone unit, which for classified use
  271.   employs individual coded ``Crypto Ignition Keys'' and a central Key
  272.   Management Center operated by NSA. There is a hierarchy in that
  273.   certain CIKs are used by authorized cryptographic control
  274.   personnel to validate the issuance of individual traffic keys and
  275.   to perform installation/maintenance functions, such as the
  276.   reporting of lost CIKs.
  277.  
  278.   This should give an inkling of the extent of the key management
  279.   problem. For public-key systems, there are several related issues,
  280.   many having to do with ``whom do you trust?''
  281.  
  282. 8.10. Can I use pseudo-random or chaotic numbers as a key stream?
  283.  
  284.   Chaotic equations and fractals produce an apparent randomness from
  285.   relatively compact generators. Perhaps the simplest example is a
  286.   linear congruential sequence, one of the most popular types of random
  287.   number generators, where there is no obvious dependence between seeds
  288.   and outputs. Unfortunately the graph of any such sequence will, in a
  289.   high enough dimension, show up as a regular lattice. Mathematically
  290.   this lattice corresponds to structure which is notoriously easy for
  291.   cryptanalysts to exploit. More complicated generators have more
  292.   complicated structure, which is why they make interesting pictures---
  293.   but a cryptographically strong sequence will have no computable
  294.   structure at all.
  295.  
  296.   See [KNU81], exercise 3.5-7; [REE77]; and [BOY89].
  297.  
  298. 8.11. What is the correct frequency list for English letters?
  299.  
  300.   There are three answers to this question, each slightly deeper than
  301.   the one before. You can find the first answer in various books:
  302.   namely, a frequency list computed directly from a certain sample of
  303.   English text.
  304.  
  305.   The second answer is that ``the English language'' varies from author
  306.   to author and has changed over time, so there is no definitive list.
  307.   Of course the lists in the books are ``correctly'' computed, but
  308.   they're all different: exactly which list you get depends on which
  309.   sample was taken. Any particular message will have different
  310.   statistics from those of the language as a whole.
  311.  
  312.   The third answer is that yes, no particular message is going to have
  313.   exactly the same characteristics as English in general, but for all
  314.   reasonable statistical uses these slight discrepancies won't matter.
  315.   In fact there's an entire field called ``Bayesian statistics'' (other
  316.   buzzwords are ``maximum entropy methods'' and ``maximum likelihood
  317.   estimation'') which studies questions like ``What's the chance that a
  318.   text with these letter frequencies is in English?'' and comes up with
  319.   reasonably robust answers.
  320.  
  321.   So make your own list from your own samples of English text. It will
  322.   be good enough for practical work, if you use it properly.
  323.  
  324. 8.12. What is the Enigma?
  325.  
  326.   ``For a project in data security we are looking for sources of
  327.   information about the German Enigma code and how it was broken by
  328.   the British during WWII.''
  329.  
  330.   See [WEL82], [DEA85], [KOZ84], [HOD83], [KAH91].
  331.  
  332. 8.13. How do I shuffle cards?
  333.  
  334.   Card shuffling is a special case of the permutation of an array of
  335.   values, using a random or pseudo-random function. All possible output
  336.   permutations of this process should be equally likely. To do this, you
  337.   need a random function (modran(x)) which will produce a uniformly
  338.   distributed random integer in the interval [0..x-1]. Given that
  339.   function, you can shuffle with the following [C] code: (assuming ARRLTH
  340.   is the length of array arr[] and swap() interchanges values at the two
  341.   addresses given)
  342.  
  343.   for ( n = ARRLTH-1; n > 0 ; n-- ) swap( &arr[modran( n+1 )], &arr[n] ) ;
  344.  
  345.   modran(x) can not be achieved exactly with a simple (ranno() % x) since
  346.   ranno()'s interval may not be divisible by x, although in most cases the
  347.   error will be very small. To cover this case, one can take ranno()'s
  348.   modulus mod x, call that number y, and if ranno() returns a value less
  349.   than y, go back and get another ranno() value.
  350.  
  351.   See [KNU81] for further discussion.
  352.  
  353. 8.14. Can I foil S/W pirates by encrypting my CD-ROM?
  354.  
  355.   Someone will frequently express the desire to publish a CD-ROM with
  356.   possibly multiple pieces of software, perhaps with each encrypted
  357.   separately, and will want to use different keys for each user (perhaps
  358.   even good for only a limited period of time) in order to avoid piracy.
  359.  
  360.   As far as we know, this is impossible, since there is nothing in standard
  361.   PC or workstation hardware which uniquely identifies the user at the
  362.   keyboard. If there were such an identification, then the CD-ROM could be
  363.   encrypted with a key based in part on the one sold to the user and in
  364.   part on the unique identifier. However, in this case the CD-ROM is one
  365.   of a kind and that defeats the intended purpose.
  366.  
  367.   If the CD-ROM is to be encrypted once and then mass produced, there must
  368.   be a key (or set of keys) for that encryption produced at some stage in
  369.   the process. That key is useable with any copy of the CD-ROM's data.
  370.   The pirate needs only to isolate that key and sell it along with the
  371.   illegal copy.
  372.  
  373. 8.15. Can you do automatic cryptanalysis of simple ciphers?
  374.  
  375.   Certainly. For commercial products you can try AccessData; see
  376.   question 8.1. We are not aware of any FTP sites for such software,
  377.   but there are many papers on the subject. See [PEL79], [LUC88],
  378.   [CAR86], [CAR87], [KOC87], [KOC88], [KIN92], [KIN93], [SPI93].
  379.  
  380. 8.16. What is the coding system used by VCR+?
  381.  
  382.   One very frequently asked question in sci.crypt is how the VCR+ codes
  383.   work. The codes are used to program a VCR based on numerical input.
  384.   See [SHI92] for an attempt to describe it.
  385.